/**********************************************************

     文件名称: storage_data.c

     项目功能: 

     作者: 佳奇

     邮箱: 1374804492@qq.com 

     创建时间: Fri 26 Aug 2022 08:50:58 PM CST

**********************************************************/


#include <stdio.h>
#include <stdlib.h>
#include "sup_mgr.h"


void write_infor(cas_list* s1, com_list* s2, sales_list* s3, admin* s4)
{
	s1 = s1->next;
	s2 = s2->next;
	s3 = s3->next;
	s4 = s4->next;

	FILE* fp1 = fopen("cas_infor", "wb");
	FILE* fp2 = fopen("com_infor", "wb");
	FILE* fp3 = fopen("sales_infor", "wb");
	FILE* fp4 = fopen("admin_infor", "wb");

	if((fp1 == NULL) || (fp2 == NULL) || (fp3 == NULL) || (fp4 == NULL))
	{
		perror("fopen error!");
		return;
	}


	//	将收银员信息从链表写入到文件
	while(s1 != NULL)
	{
		fwrite(s1->data, sizeof(cas), 1, fp1);
		s1 = s1->next;
	}


	//	将商品信息从链表写入到文件
	while(s2 != NULL)
	{
		fwrite(s2->data, sizeof(com), 1, fp2);
		s2 = s2->next;
	}


	//	将销售记录信息从链表写入到文件
	while(s3 != NULL)
	{
		fwrite(s3->data, sizeof(sales), 1, fp3);
		s3 = s3->next;
	}

	//	将密码信息从链表写入到文件
	while(s4 != NULL)
	{
		fwrite(s4->data, sizeof(cry), 1, fp4);
		s4 = s4->next;
	}

	fclose(fp1);
	fclose(fp2);
	fclose(fp3);
	fclose(fp4);
}




















